<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改景点信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改景点信息</div>
                <div class="layui-card-body">
                    <form class="layui-form" action="" lay-filter="component-form-group">
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:130px;">景点名称</label>
                            <div class="layui-input-inline" style="width:230px;">
                                <input type="text" name="tour_name" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['tour_name']}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:130px;">景点电话</label>
                            <div class="layui-input-inline" style="width:230px;">
                                <input type="text" name="tour_tel" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['tour_tel']}">
                            </div>
                        </div>

                      <!--   <div class="layui-form-item">
                            <label class="layui-form-label" style="width:130px;">短信手机号</label>
                            <div class="layui-input-inline" style="width:230px;">
                                <input type="text" name="send_tel" placeholder="请输入" autocomplete="off" class="layui-input" value="{$res['send_tel']}">
                            </div>
                        </div> -->
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:130px;">酒店地区</label>
                            <div class="layui-inline">
                                <select name="province" class="province" lay-verify="required" lay-search lay-filter="province">
                                    <option value="山东省">山东省</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="city" class="city" lay-verify="required" lay-search lay-filter="city">
                                    <option value="临沂市">临沂市</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <select name="district" class="district" lay-verify="required" lay-search>
                                    <option value="沂水县">县/沂水县</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:130px;">详细地址</label>
                            <div class="layui-input-inline" style="width:230px;">
                                <input type="text" value="{$res['address']}" name="address" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:130px;">景点类型</label>
                            <div class="layui-input-inline" style="width: 230px;">
                                <select name="type" lay-verify="required">
                                    <option value=""></option>
                                    <option value="1" {if condition="$res.type == 1"}selected="selected"{/if}>人文景玩</option>
                                    <option value="2" {if condition="$res.type == 2"}selected="selected"{/if}>自然景观</option>
                                    <option value="3" {if condition="$res.type == 3"}selected="selected"{/if}>温泉度假</option>
                                    <option value="4" {if condition="$res.type == 4"}selected="selected"{/if}>亲子游</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:130px;">景点标签</label>
                            <div class="layui-input-inline" style="width:230px;">
                                <input type="text" value="{$res.tour_tag}" name="tour_tag" lay-verify="required" placeholder="请输入景点标签，多个标签用英文逗号（,）隔开" autocomplete="off" class="layui-input">
                            </div>
                            <label class="layui-form-label" style="width:200px;">多个标签用英文逗号（,）隔开</label>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: 130px">营业开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="start" name="team_start_time" placeholder="请输入活动开启时间" lay-verify="required" value="{$start}">
                            </div>
                            <label class="layui-form-label" style="width: 130px">营业结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" id="end" name="team_end_time" placeholder="请输入活动结束时间" lay-verify="required" value="{$end}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width:130px;padding-top: 0;padding-bottom:0;height: 105px;line-height: 105px;">店铺封面</label>
                            <div class="layui-input-inline" style="border:1px solid #888888;width:105px;height: 105px;">
                                <img src="{$res.tour_covers}" id="tour_covers_src" style=" display:block;width:105px;height: 105px;" alt="" name="">
                                <input type="hidden" value="{$res.tour_covers}" name="tour_covers" id="covers">
                            </div>
                            <div class="layui-input-inline" style="padding-top: 0;padding-bottom:0;height: 105px;line-height: 105px;">
                                <a class="layui-btn" id="upload_covers_button">上传</a>
                            </div>
                        </div>
                        <input type="hidden" value="{$tour_id}" name="tour_id">
                        <div class="layui-form-item layui-layout-admin">
                            <div class="layui-input-block">
                                <div class="layui-inline" style="left: 0;">
                                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="addsubmit">修改</button>
                                    <a class="layui-btn layui-btn-primary prex" data-type="prex">返回</a>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script src="/static/js/jquery-1.11.1.min.js"></script>
<script src="/static/js/area.js" type="text/javascript"></script>
<script src="/static/js/selectMore.js" type="text/javascript"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','set','upload','laydate'], function(){
        $ = layui.jquery;
        var  admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,form = layui.form
            ,laydate = layui.laydate
            ,upload=layui.upload;

        form.render(null,'component-form-group');
        //时间选择器
        laydate.render({
            elem: '#start'
            ,type: 'time'
            ,format:"HH:mm"
        });

        laydate.render({
            elem: '#end'
            ,type: 'time'
            ,format:"HH:mm"
        });
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#upload_covers_button'
            ,url: "{:url('Common/upload')}"
            ,done: function(res){
                if (res.code == 1){
                    return layer.msg(res.msg,{time:1500},function(){
                        $('#tour_covers_src').attr('src',res.data);
                        $('#covers').val(res.data);
                    });
                }else{
                    return layer.msg(res.msg);
                }
            }
        });
        //添加提交
        form.on('submit(addsubmit)', function(data){


            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });

            $.ajax({
                url: "{:url('Merchant/editView')}",
                type: 'post',
                dataType: 'json',
                data: {data:data.field},
                success: function(data){
                    if (data.code === 0) {
                        layer.msg('修改成功',{icon:1,time:2000},function(){
                            window.location.href = "{:url('Merchant/view')}";
                        });
                    }else if(data.code === 2){
                        layer.close(loading);
                        layer.msg('修改失败',{icon:2,time:1000})
                    }else if(data.code === 1){
                        layer.close(loading);
                        layer.msg('修改内容不能为空',{icon:2,time:1000})
                    }else if(data.code === 3){
                        layer.close(loading);
                        layer.msg('手机号已经存在',{icon:2,time:1000})
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });


        var $ = layui.$, active = {
            prex:function(){
                layer.confirm('确认取消本次编辑并返回吗？',function(){
                    window.location.href="{:url('Merchant/view')}";
                });
            }
        };

        $('.prex').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>